/*
 * =====================================================================================
 *
 *       Filename:  str_regex.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  07/04/15 08:03:15
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andy (gk), andy_y_li@163.com
 *        Company:  RD
 *
 * =====================================================================================
 */

#ifndef _STR_REGEX_H
#define _STR_REGEX_H

#include <iostream>
#include<stdio.h>
#include<sys/types.h>
#include<regex.h>

typedef enum {
    OK = 0,
    FATAL_ERROR,
    NO_MATCH,
} PatternErrorCode;

class StrPattern{
    PatternErrorCode _result;
    const char *_str;
    int _matchCount;
    regex_t reg;
    regmatch_t *pmatch;
    char *msgBuf;

    public:
        StrPattern(const char *str, const char *pattern, int pmatchLength = 10);
        ~StrPattern();
        PatternErrorCode result();
        int matchCount();
        const char *getMatchString(int index);
};

#endif

